home *** CD-ROM | disk | FTP | other *** search
-
- var comboBoxArray = new Array();
- var IPcomboBoxArray = new Array();
-
- function CreateComboBoxObject(strDropDownListID, strComboBoxName)
- {
- this.Mycmb = document.all[strDropDownListID];
- this.SetDefaultText = SetDefaultText;
- this.Mycmb.selectedIndex = -1;
- this.UseStateFunctions = false;
- this.Clear = Clear;
- this.GetSelectedText = GetSelectedText;
- this.AlignTextBoxOverDropDown = AlignTextBoxOverDropDown;
- this.cbo_OnChange = cbo_OnChange;
- this.txt_OnBlur = txt_OnBlur;
- this.setDefaultIndex = setDefaultIndex;
- this.txt_OnKeyUp = txt_OnKeyUp;
- this.focus = focus;
- //do lookup or not
- this.LookupValues = true;
- this.SetAccessKey = SetAccessKey;
- //case sensitivity
- this.LookupCaseInSensitive = true;
- //store the previous text for the lookup
- this.MytxtPreviousValue = "";
- //generate the text box on the fly
-
- var strMytxtID = "txtMytxt" + strDropDownListID;
-
- var strMytxt = "<INPUT type='text' id=" + strMytxtID + " name=" + strMytxtID + " onblur='" + strComboBoxName + ".txt_OnBlur()' " +
- " onkeyup='" + strComboBoxName + ".txt_OnKeyUp()' " +
- " style='display: none; position: absolute' value='' >";
-
- this.Mycmb.insertAdjacentHTML("afterEnd", strMytxt);
- //assign obj to new textbox
- this.Mytxt = document.all[strMytxtID];
-
- var strMyHiddentxtID = strDropDownListID + "_value";
-
- var strMyHiddentxt = "<INPUT type='hidden' " + " id=" + strMyHiddentxtID + " name=" + strMyHiddentxtID + " >";
-
- this.Mycmb.insertAdjacentHTML("afterEnd", strMyHiddentxt);
- this.MyHiddentxt = document.all[strMyHiddentxtID];
-
- this.AdjustingSize = false;
- this.AlignTextBoxOverDropDown();
-
- comboBoxArray[comboBoxArray.length] = this;
- }
-
- function SetAccessKey(Key)
- {
- this.Mytxt.accessKey = Key;
- }
-
- function CreateIPComboBoxObject(strDropDownListID, strComboBoxName)
- {
- this.MyIPcmb = document.all[strDropDownListID];
- this.MyIPcmb.selectedIndex = -1;
- this.UseStateFunctions = false;
- this.AlignIPCombo = AlignIPCombo;
- this.cboIP_OnChange = cboIP_OnChange;
- this.cboIPRange_OnChange = cboIPRange_OnChange;
- this.UseStateFunctions = false;
- this.AdjustingSize = false;
- this.IPAddressArrowUp = IPAddressArrowUp;
- this.IPAddressArrowDown = IPAddressArrowDown;
- this.IPRangeAddressArrowUp = IPRangeAddressArrowUp;
- this.IPRangeAddressArrowDown = IPRangeAddressArrowDown;
- this.AlignIPCombo();
-
- IPcomboBoxArray[IPcomboBoxArray.length] = this;
- }
-
- function AlignIPCombos()
- {
- var iIndex;
- for (iIndex=0; iIndex < comboBoxArray.length; iIndex++)
- {
- IPcomboBoxArray[iIndex].AlignIPCombo();
- }
- }
-
- function AlignIPCombo()
- {
- if (!this.AdjustingSize)
- {
- this.AdjustingSize = true;
- this.MyIPcmb.style.position="static";
-
- this.MyIPcmb.style.position ="absolute";
- this.MyIPcmb.style.posLeft = GetAbsoluteXPosition(document.getElementById("IP1"))
- this.MyIPcmb.style.posTop = GetAbsoluteYPosition(document.getElementById("IP1"));
-
- if(document.all["IP1"].clientWidth >29)
- {
- if(document.all["IP5"] != null && document.all["IP5"] != 'undefined')
- {//must be an IP Range
- this.MyIPcmb.style.width = "405px";
- }
- else
- {//single IP
- this.MyIPcmb.style.width = "190px";
- }
- var strClipRectangle = "rect(0 " +
- (this.MyIPcmb.offsetWidth) + " " +
- this.MyIPcmb.offsetHeight + " " +
- (this.MyIPcmb.offsetWidth - 20) + ")";
- }
- else
- {
- var strClipRectangle = "rect(0 " +
- (this.MyIPcmb.offsetWidth) + " " +
- this.MyIPcmb.offsetHeight + " " +
- (this.MyIPcmb.offsetWidth - 18 ) + ")";
- }
- this.MyIPcmb.style.clip = strClipRectangle;
- this.AdjustingSize = false;
- }
- }
-
- function AlignTextBoxesOverDropDowns()
- {
- var iIndex;
- for (iIndex=0; iIndex < comboBoxArray.length; iIndex++)
- {
- comboBoxArray[iIndex].AlignTextBoxOverDropDown();
- }
- }
-
- //sets the default option
- function SetDefaultText(Text)
- {
-
- this.Mycmb.selectedIndex = -1;
- this.Mytxt.value = Text;
- }
-
-
- //Move the textbox over the Combo
- function AlignTextBoxOverDropDown()
- {
- if (!this.AdjustingSize)
- {
- this.AdjustingSize = true;
- this.Mytxt.style.display="none";
- this.Mycmb.style.position="static";
-
- this.Mytxt.style.posLeft = GetAbsoluteXPosition(this.Mycmb);
- this.Mytxt.style.posTop = GetAbsoluteYPosition(this.Mycmb) + 1;
- this.Mytxt.style.posWidth = this.Mycmb.offsetWidth - 16; // 16 THIS IS THE WIDTH OF THE DROP DOWN ARROW
- this.Mytxt.style.posHeight = this.Mycmb.offsetHeight;
-
- this.Mycmb.style.position ="absolute";
- this.Mycmb.style.posLeft = this.Mytxt.style.posLeft;
- this.Mycmb.style.posTop = this.Mytxt.style.posTop;
-
- this.ComboWidth = this.Mycmb.offsetWidth;
- var strClipRectangle = "rect(0 " +
- (this.Mycmb.offsetWidth) + " " +
- this.Mycmb.offsetHeight + " " +
- (this.Mytxt.style.posWidth -5 ) + ")";
-
- this.Mycmb.style.clip = strClipRectangle;
- this.Mytxt.style.display="";
- this.AdjustingSize = false;
- }
-
- }
-
- function Clear()
- {
- this.Mytxt.value = "";
- this.Mycmb.selectedIndex = -1;
- }
-
- function GetAbsoluteXPosition(element)
- {
- var pos = 0;
- while (element != null)
- {
- pos += element.offsetLeft;
- element = element.offsetParent;
- }
-
- return pos;
- }
-
- function GetAbsoluteYPosition(element)
- {
- var pos = 0;
-
- while (element != null )
- {
- pos += element.offsetTop;
- element = element.offsetParent;
- }
-
- return pos;
- }
-
- function GetSelectedText()
- {
- return this.Mytxt.value;
- }
-
- function cboIP_OnChange()
- {
- var tmpIndex = this.MyIPcmb.selectedIndex;
- var tempOption = this.MyIPcmb.options[tmpIndex];
-
- var IPArr = tempOption.text.split(".")
- document.all["IP1"].value = IPArr["0"];
- document.all["IP2"].value = IPArr["1"];
- document.all["IP3"].value = IPArr["2"];
- document.all["IP4"].value = IPArr["3"];
-
- this.MyIPcmb.selectedIndex=-1;
- if(this.UseStateFunctions)
- {
- SetState("IP");
- }
- }
-
- function cboIPRange_OnChange()
- {
- var tmpIndex = this.MyIPcmb.selectedIndex;
- var tempOption = this.MyIPcmb.options[tmpIndex];
-
- var IPArr = tempOption.text.split("to")
- var IP1 = IPArr["0"].split(".");
- var IP2 = IPArr["1"].split(".");
-
- document.all["IP1"].value = IP1["0"];
- document.all["IP2"].value = IP1["1"];
- document.all["IP3"].value = IP1["2"];
- document.all["IP4"].value = IP1["3"].substring(0,IP1["3"].length-1);
- document.all["IP5"].value = IP2["0"].substring(1,IP2["0"].length);
- document.all["IP6"].value = IP2["1"];
- document.all["IP7"].value = IP2["2"];
- document.all["IP8"].value = IP2["3"];
-
- if(this.UseStateFunctions)
- {
- SetState("IP");
- }
- this.MyIPcmb.selectedIndex=-1;
- }
-
- function cbo_OnChange()
- {
- var tmpIndex = this.Mycmb.selectedIndex;
- var tempOption = this.Mycmb.options[tmpIndex];
- this.Mytxt.value = tempOption.text;
-
- this.Mytxt.focus();
- this.Mytxt.select();
-
- if(this.UseStateFunctions)
- {
- SetState("CPU");
- }
- this.Mycmb.selectedIndex=-1;
- }
-
- function txt_OnKeyUp()
- {
- if (this.LookupValues)
- {
- if (event.keyCode < 32)
- {
- return;
- }
- else if (event.keyCode == 46)
- {
- return;
- }
- else if (event.keyCode == 38)//up arrow
- {
- var len = this.Mycmb.options.length;
- if(len > 0)
- {
- var tempString;
- var curText = this.Mytxt.value;
- var FoundIndex = -1;
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.Mycmb.options(iIndex).text;
-
- tempString = tempString.toUpperCase();
- curText = curText.toUpperCase();
- if (tempString == curText)
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- }
- else
- {
- if(FoundIndex > 0)
- {
- this.Mytxt.value = this.Mycmb.options(FoundIndex -1).text;
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", this.Mytxt.length);
- tmpRange.select();
- SetState("CPU");
- }
- }
- }
- return;
- }
- else if (event.keyCode == 40)//Down arrow
- {
- var len = this.Mycmb.options.length;
- if(len > 0)
- {
- var tempString;
- var curText = this.Mytxt.value;
- var FoundIndex = -1;
-
- for (var iIndex=0; iIndex<len; iIndex++)
- {
-
- tempString = this.Mycmb.options(iIndex).text;
- tempString = tempString.toUpperCase();
- curText = curText.toUpperCase();
- if (tempString == curText)
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- this.Mytxt.value = this.Mycmb.options(0).text;
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", this.Mytxt.length);
- tmpRange.select();
- SetState("CPU");
- }
- else
- {
- if(FoundIndex < this.Mycmb.options.length - 1)
- {
- this.Mytxt.value = this.Mycmb.options(FoundIndex + 1).text;
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", this.Mytxt.length);
- tmpRange.select();
- SetState("CPU");
- }
- }
- }
- return;
- }
- if(this.UseStateFunctions)
- {
- SetState("CPU");
- }
- var curText = this.Mytxt.value;
- var prevText = this.MytxtPreviousValue;
- var iIndex;
-
- if ((curText == "") || (curText == prevText))
- {
- this.MytxtPreviousValue = curText;
- return;
- }
-
- var len = this.Mycmb.options.length;
- var tempString;
-
- for (iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.Mycmb.options(iIndex).text;
-
- if (this.LookupCaseInSensitive)
- {
- tempString = tempString.toUpperCase();
- curText = curText.toUpperCase();
- }
-
- if (tempString.indexOf(curText) == 0)
- {
- var helperString = this.Mycmb.options(iIndex).text;
-
- this.Mytxt.value = this.Mytxt.value + helperString.substr(curText.length);
- this.Mycmb.selectedIndex = iIndex;
- this.MytxtPreviousValue = this.Mytxt.value;
-
- var tmpRange = this.Mytxt.createTextRange();
- tmpRange.moveStart("character", curText.length);
- tmpRange.select();
- return;
- }
- }
- }
- }
-
- function txt_OnBlur()
- {
- var myDropDownList = this.Mycmb;
- var myEditCell = this.Mytxt;
- var myHiddenCell = this.MyHiddentxt;
- var iIndex;
-
- myHiddenCell.value = myEditCell.value;
- myDropDownList.selectedIndex = -1;
-
- if (myEditCell.value == "")
- {
- return;
- }
-
- var len = myDropDownList.options.length;
- for (iIndex=0; iIndex<len; iIndex++)
- {
- var str1 = myDropDownList.options(iIndex).text;
- var str2 = myEditCell.value;
-
- if (this.LookupCaseInSensitive)
- {
- str1 = str1.toUpperCase();
- str2 = str2.toUpperCase();
- }
-
- if (str1 == str2)
- {
- myDropDownList.selectedIndex = iIndex;
- myHiddenCell.value = myDropDownList.options(iIndex).value;
- return;
- }
- }
-
- if (this._bOnlyAllowedEntries)
- {
- myDropDownList.focus();
-
- alert("'" + myEditCell.value + "' is not allowed");
- this.Mycmb.selectedIndex = -1;
- this.Mytxt.select();
-
- return;
- }
- }
-
- function focus()
- {
- this.Mycmb.focus();
- }
-
- function setDefaultIndex(iIndex)
- {
- var len = this.Mycmb.options.length;
- if ((iIndex >=0) && (iIndex < len))
- {
- this.Mycmb.selectedIndex = iIndex;
- this.Mytxt.value = this.Mycmb.options(iIndex).text;
- this.MyHiddentxt.value = this.Mycmb.options(iIndex).value;
- return;
- }
-
- this.Mytxt.value = "";
- }
-
- function IPAddressArrowUp(curText)
- {
- var len = this.MyIPcmb.options.length;
- if(len > 0)
- {
- var tempString;
- var FoundIndex = -1;
- var NewValue = "";
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
- if (tempString.toString() == curText.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- NewValue = curText;
- }
- else
- {
- if(FoundIndex > 0)
- {
- NewValue = this.MyIPcmb.options(FoundIndex -1).text;
- }
- }
- return NewValue;
- }
- else
- return "";
- }
- function IPAddressArrowDown(curText)
- {
- var len = this.MyIPcmb.options.length;
- if(len > 0)
- {
- var tempString;
- var NewValue = "";
- var FoundIndex = -1;
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
-
- if (tempString.toString() == curText.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- NewValue = this.MyIPcmb.options(0).text;
- }
- else
- {
- if(FoundIndex < this.MyIPcmb.options.length - 1)
- {
- NewValue = this.MyIPcmb.options(FoundIndex + 1).text;
- }
- }
-
- return NewValue;
- }
- else
- return "";
- }
-
- function IPRangeAddressArrowUp(curText)
- {
- var len = this.MyIPcmb.options.length;
-
- if(len > 0)
- {
- var curIPArr = curText.split("to");
- var curIP1 = curIPArr["0"].substring(0,curIPArr["0"].length -1);
- var curIP2 = curIPArr["1"].substring(1,curIPArr["1"].length -1);
-
- var tempString;
- var FoundIndex = -1;
- var NewValue = "";
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
-
- var IPArr = tempString.split("to");
- var IP1 = IPArr["0"].substring(0,IPArr["0"].length -1);
- var IP2 = IPArr["1"].substring(1,IPArr["1"].length -1);
- if (curIP1.toString() == IP1.toString() && curIP2.toString() == IP2.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- NewValue = curText;
- }
- else
- {
- if(FoundIndex > 0)
- {
- NewValue = this.MyIPcmb.options(FoundIndex -1).text;
- }
- }
- return NewValue;
- }
- else
- return "";
- }
-
- function IPRangeAddressArrowDown(curText)
- {
- var len = this.MyIPcmb.options.length;
-
- if(len > 0)
- {
- var curIPArr = curText.split("to");
- var curIP1 = curIPArr["0"].substring(0,curIPArr["0"].length -1);
- var curIP2 = curIPArr["1"].substring(1,curIPArr["1"].length -1);
-
- var tempString;
- var FoundIndex = -1;
- var NewValue = "";
- for (var iIndex=0; iIndex<len; iIndex++)
- {
- tempString = this.MyIPcmb.options(iIndex).text;
-
- var IPArr = tempString.split("to");
- var IP1 = IPArr["0"].substring(0,IPArr["0"].length -1);
- var IP2 = IPArr["1"].substring(1,IPArr["1"].length -1);
- if (curIP1.toString() == IP1.toString() && curIP2.toString() == IP2.toString())
- {
- FoundIndex = iIndex;
- }
- }
- if(FoundIndex == -1)
- {
- //do nothing
- NewValue = curText;
- }
- else
- {
- if(FoundIndex < this.MyIPcmb.options.length - 1)
- {
- NewValue = this.MyIPcmb.options(FoundIndex + 1).text;
- }
- }
- return NewValue;
- }
- else
- return "";
-
- }
-